package com.hoshiicloud.fileserver.config;

import com.obs.services.ObsClient;
import com.obs.services.ObsConfiguration;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

/**
   *   华为云obs配置类
 * @author Mr.wu
 *
 */
@Configuration
public class ObsConfig {
	
	public static String accessKey;
	
	public static String secretAccessKey;
	
	public static String defaultEndpoint;


	@Value("${obs.accessKey}")
	public void setAccessKey(String accessKey) {
		ObsConfig.accessKey = accessKey;
	}

	@Value("${obs.secretAccessKey}")
	public void setSecretAccessKey(String secretAccessKey) {
		ObsConfig.secretAccessKey = secretAccessKey;
	}
	@Value("${obs.defaultEndpoint}")
	public void setDefaultEndpoint(String defaultEndpoint) {
		ObsConfig.defaultEndpoint = defaultEndpoint;
	}

	public static ObsConfiguration getDefaultConfig() {
		ObsConfiguration obsConfiguration=new ObsConfiguration();
		obsConfiguration.setEndPoint(defaultEndpoint);
		return obsConfiguration;
	}
	public static ObsClient getDefaultObsClient(){
		ObsClient obsClient=new ObsClient(ObsConfig.accessKey,ObsConfig.secretAccessKey,ObsConfig.getDefaultConfig());
		return obsClient;
	}

	public static String getAccessKey() {
		return accessKey;
	}

	public static String getSecretAccessKey() {
		return secretAccessKey;
	}

	public static String getDefaultEndpoint() {
		return defaultEndpoint;
	}
}
